<template>
   <div>
          <!-- 循环表-->
       <el-table  :data="tableData"  border   row-key="id" default-expand-all>
            <el-table-column
                fixed
                prop="permissionID"
                label="权限ID"
                width="150">
            </el-table-column>
            <el-table-column
                fixed
                prop="permissionName"
                label="权限名称"
                width="150">
            </el-table-column>
            <el-table-column
                fixed
                prop="permissionState.permissionStateName"
                label="状态"
                width="200">
            </el-table-column>
            <el-table-column
                fixed
                prop="comments"
                label="备注"
                width="300">
            </el-table-column>
            <el-table-column
                fixed="right"
                label="操作"
                width="250">
                <template slot-scope="scope">
                    <el-button style="margin:2%" type="danger" plain  @click="edit(scope.$index, tableData)" icon="el-icon-error">禁用</el-button>
                     <el-button style="margin:2%" type="primary" plain  @click="edit2(scope.$index, tableData)" icon="el-icon-success">启用</el-button>
                </template> 
            </el-table-column>
       </el-table> 
   </div>
</template>
<script>
import $axios from 'axios'

export default {
    data(){
        return {
              tableData: [],
              permissionStateID:'',
        }
    },
    created(){
        this.show();
    },
    methods:{
        show(){
            // console.log("show")
            $axios.get("https://localhost:44328/OA_Permission/GetPermissions")
            .then((result)=>{
                this.tableData=result.data               
            })
        },
        edit(index, rows){        
             $axios.put('https://localhost:44328/OA_Permission/Update_QiYong_Sate?PermissonID=' + rows[index].permissionID).then((result) => {
                if (result.data == 1) {
                    this.$message({
                        message: '禁用成功',
                        type: 'success',
                    });
                    this.show();
                } else {
                    this.$message({
                        message: '禁用已成功,不可以再禁用',
                        type: 'error'
                    });
                }
            });
        },
         edit2(index, rows){
             $axios.put('https://localhost:44328/OA_Permission/Update_JinYong_Sate?PermissonID=' + rows[index].permissionID).then((result) => {
                if (result.data == 1) {
                    this.$message({
                        message: '启用成功',
                        type: 'success',
                    });
                    this.show();
                } else {
                    this.$message({
                        message: '启用已成功,不可以再启用',
                        type: 'error'
                    });
                }
            });
        }
    }
}
</script>
<style scoped>

</style>